libtorrent-rasterbar: enable python package
authorTianling Shen <[email protected]>
Tue, 22 Apr 2025 13:52:38 +0000 (21:52 +0800)
committerTianling Shen <[email protected]>
Thu, 24 Apr 2025 11:34:58 +0000 (19:34 +0800)
The python package now works with Python 3.11.

Also simplify Build/InstallDev with CMAKE_INSTALL.

Signed-off-by: Tianling Shen <[email protected]>
libs/libtorrent-rasterbar/Makefile

index 26201d05223c62447f00c854814488c1c7e506ed..93ea1cab4173a4b418b01f518110980f3a031452 100644 (file)
@@ -12,51 +12,72 @@ PKG_MAINTAINER:=David Yang <[email protected]>
 PKG_LICENSE:=BSD-3-Clause
 PKG_LICENSE_FILES:=COPYING
 
+PKG_CONFIG_DEPENDS:=CONFIG_PACKAGE_python3-libtorrent
+
+CMAKE_INSTALL:=1
+PYTHON3_PKG_BUILD:=0
+PYTHON3_PKG_WHEEL_NAME:=libtorrent
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
+include ../../lang/python/python3-package.mk
 
 define Package/libtorrent-rasterbar/Default
-       TITLE:=Rasterbar BitTorrent library
-       URL:=https://libtorrent.org/
+  TITLE:=Rasterbar BitTorrent library
+  URL:=https://libtorrent.org/
 endef
 
 define Package/libtorrent-rasterbar
-       $(call Package/libtorrent-rasterbar/Default)
-       SECTION:=libs
-       CATEGORY:=Libraries
-       DEPENDS:=+boost-system +libopenssl +libatomic +libstdcpp
+  $(call Package/libtorrent-rasterbar/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+boost-system +libopenssl +libatomic +libstdcpp
 endef
 
-#define Package/python3-libtorrent
-#      $(call Package/libtorrent-rasterbar/Default)
-#      SECTION:=lang
-#      CATEGORY:=Languages
-#      SUBMENU:=Python
-#      TITLE+= (Python 3)
-#      DEPENDS:=+libtorrent-rasterbar +boost-python
-#endef
+define Package/python3-libtorrent
+  $(call Package/libtorrent-rasterbar/Default)
+  SECTION:=lang
+  CATEGORY:=Languages
+  SUBMENU:=Python
+  TITLE+= (Python 3)
+  DEPENDS:=+libtorrent-rasterbar +boost-python3
+endef
 
 define Package/libtorrent-rasterbar/description
-       Rasterbar libtorrent is a C++ library that aims to be a good alternative to
-       all the other bittorrent implementations around.
+  Rasterbar libtorrent is a C++ library that aims to be a good alternative to
+  all the other bittorrent implementations around.
 endef
 
-#define Package/python3-libtorrent/description
-#      $(call Package/libtorrent-rasterbar/description)
-#      This package contains Python 3 bindings for the libtorrent-rasterbar library.
-#endef
+define Package/python3-libtorrent/description
+  $(call Package/libtorrent-rasterbar/description)
+  This package contains Python 3 bindings for the libtorrent-rasterbar library.
+endef
 
-#CMAKE_OPTIONS += \
-#      -Dpython-bindings=ON \
-#      -Dpython-egg-info=ON
+ifneq ($(CONFIG_PACKAGE_python3-libtorrent),)
+CMAKE_OPTIONS += \
+       -Dpython-bindings=ON \
+       -Dpython-egg-info=ON
+endif
 
-define Build/InstallDev
-       $(INSTALL_DIR) $(1)/usr/include
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/libtorrent $(1)/usr/include/
-       $(INSTALL_DIR) $(1)/usr/lib
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libtorrent-rasterbar.so* $(1)/usr/lib/
-       $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libtorrent-rasterbar.pc $(1)/usr/lib/pkgconfig/
+define Build/Configure
+       $(call Build/Configure/Default)
+ifneq ($(CONFIG_PACKAGE_python3-libtorrent),)
+       $(call Py3Build/Configure)
+endif
+endef
+
+define Build/Compile
+       $(call Build/Compile/Default)
+ifneq ($(CONFIG_PACKAGE_python3-libtorrent),)
+       $(call Py3Build/Compile)
+endif
+endef
+
+define Build/Install
+       $(call Build/Install/Default)
+ifneq ($(CONFIG_PACKAGE_python3-libtorrent),)
+       $(call Py3Build/Install/Default)
+endif
 endef
 
 define Package/libtorrent-rasterbar/install
@@ -64,10 +85,6 @@ define Package/libtorrent-rasterbar/install
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libtorrent-rasterbar.so.* $(1)/usr/lib/
 endef
 
-#define Package/python3-libtorrent/install
-#      $(INSTALL_DIR) $(1)/usr/lib/python2.7/site-packages
-#      $(CP) $(PKG_INSTALL_DIR)/usr/lib/python2.7/site-packages/*.so* $(1)/usr/lib/python2.7/site-packages/
-#endef
-
 $(eval $(call BuildPackage,libtorrent-rasterbar))
-#$(eval $(call BuildPackage,python3-libtorrent))
+$(eval $(call Py3Package,python3-libtorrent))
+$(eval $(call BuildPackage,python3-libtorrent))